/**
 * 
 * @param {String} c
 * @return {String}
 */
String.prototype.removeLastChar = function (c){
	return this.replace(/.$/g, '');
};

/**
 * 
 * @param {String} str
 * @return {Boolean}
 */
String.prototype.endsWith = function(str) {
	return this.match(str+"$") == str;
};

/**
 * 
 * @returns {Array}
 */
Array.prototype.clone = function () {
	var arr1 = new Array(); 
	for (var property in this) {
		arr1[property] = typeof (this[property]) == 'object' ? this[property].clone() : this[property];
	}
	return arr1;
};

/**
 * @function removeAll
 */
Ext.data.Store.prototype.removeAll = function() {
	while (this.getCount()>0){
		this.removeAt(0);
	}	
};

/**
 * @ignore
 * OpenLayers.Tile.Image prototype, resize için
 * ?? kullanılıyor mu ??
 */

OpenLayers.Tile.Image.prototype.startTransition = function (){
    // backBufferTile has to be valid and ready to use
    if (!this.backBufferTile || !this.backBufferTile.imgDiv) {
        return;
    }

    // calculate the ratio of change between the current resolution of the
    // backBufferTile and the layer.  If several animations happen in a
    // row, then the backBufferTile will scale itself appropriately for
    // each request.
    var ratio = 1;
    if (this.backBufferTile.resolution) {
        ratio = this.backBufferTile.resolution / this.layer.getResolution();
    }
    
    // if the ratio is not the same as it was last time (i.e. we are
    // zooming), then we need to adjust the backBuffer tile
    if (true || ratio != this.lastRatio) {
    	ration = 2;
        if (this.layer.transitionEffect == 'resize') {
            // In this case, we can just immediately resize the 
            // backBufferTile.
            var upperLeft = new OpenLayers.LonLat(
                this.backBufferTile.bounds.left, 
                this.backBufferTile.bounds.top
            );
            var size = new OpenLayers.Size(
                this.backBufferTile.size.w * ratio,
                this.backBufferTile.size.h * ratio
            );

            var px = this.layer.map.getLayerPxFromLonLat(upperLeft);
            OpenLayers.Util.modifyDOMElement(this.backBufferTile.frame, 
                                             null, px, size);
            console.log("x: " + px.x + ", y: " + px.y);
            var imageSize = this.backBufferTile.imageSize;
            imageSize = new OpenLayers.Size(imageSize.w * ratio, 
                                            imageSize.h * ratio);
            var imageOffset = this.backBufferTile.imageOffset;
            if(imageOffset) {
                imageOffset = new OpenLayers.Pixel(
                    imageOffset.x * ratio, imageOffset.y * ratio
                );
            }

            OpenLayers.Util.modifyDOMElement(
                this.backBufferTile.imgDiv, null, imageOffset, imageSize
            ) ;

            this.backBufferTile.show();
        }
    } else {
        // default effect is just to leave the existing tile
        // until the new one loads if this is a singleTile and
        // there was no change in resolution.  Otherwise we
        // don't bother to show the backBufferTile at all
        if (this.layer.singleTile) {
            this.backBufferTile.show();
        } else {
            this.backBufferTile.hide();
        }
    }
    this.lastRatio = ratio;	
};
